<template>
  <view class="template-product tn-safe-area-inset-bottom">
    <!-- 顶部自定义导航 -->
    <tn-nav-bar :isBack="true"  backgroundColor="#4169E1" class="tatils">推荐码</tn-nav-bar>
    <view :style="{height: vuex_custom_bar_height + 'px'}" ></view>
	<view  style="padding: 5px;background-color: #fff;display: block;">
		<image :src="src" style="display: block;width: 260px;height: 260px;margin: 0 auto;margin-top: 20px;"></image>
	</view>
	<!-- <view v-if="uinfo.pstatus==1" style="padding: 5px;background-color: #fff;display: block;">
		<view style="text-align: center;font-size: 16px;width: 200px;
			border-radius: 20px;margin: 0 auto;margin-top: 30%;height: 40px;
			background-color: #3465CC;line-height: 40px;color: #fff;">申请中</view>
	</view>
	<view v-if="uinfo.pstatus=='' || uinfo.pstatus==null" style="padding: 5px;background-color: #fff;display: block;">
		<view @click="getUserEdits" style="text-align: center;font-size: 16px;width: 200px;
		border-radius: 20px;margin: 0 auto;margin-top: 30%;height: 40px;background-color: #3465CC;line-height: 40px;color: #fff;">申请推荐码</view>
	</view>
	<view v-if="uinfo.pstatus==3" style="padding: 5px;background-color: #fff;display: block;">
		<view style="text-align: center;font-size: 16px;width: 200px;
			border-radius: 20px;margin: 0 auto;margin-top: 30%;height: 40px;
			background-color: #3465CC;line-height: 40px;color: #fff;">不好意思 您的申请被驳回了</view>
		
	</view> -->
  </view>
</template>

<script>
	import QRCode from 'qrcode';
	import {getToken,setToken,removeToken,getLogins} from '@/utils/auth';
	import {
		gethydetail
	} from '@/apis/index.js'
	import {
		getUserEdit
	} from '@/apis/user.js'
	
	
  import template_page_mixin from '@/libs/mixin/template_page_mixin.js'
  export default {
    name: 'TemplateProduct',
    mixins: [template_page_mixin],
    data(){
      return {
			src:'',
			uid:'',
			uinfo:''
        }
    },
	onLoad(opent) {
		getLogins()
		this.uid = uni.getStorageSync('uid');
		console.log(uni.getStorageSync('uinfo'))
		this.uinfo = uni.getStorageSync('uinfo');
		this.gtotg()
	},
    methods: {
		getUserEdits(){
			let data = {
				id:this.uid,
				pstatus:1,
			}
			getUserEdit(data).then(res => {
					setToken(res.data.id)
					uni.setStorageSync('uid', res.data.id);
					uni.setStorageSync('uinfo', res.data);
					this.uinfo = res.data
					this.$tn.message.toast(`已申请推荐码`)
				}).catch(error => {
					this.tool.toastTip('请稍后重试!', 'none', 1000)
				})
		},
		
		
		
		gtotg(){
			let urls = 'http://cs4.hephp.cn/index/Users/imagechack?uid='+this.uid
			QRCode.toDataURL(urls)
			        .then(url => {
			            this.src = url;
			        })
			        .catch(err => {
			            console.error(err)
			        })
			this.show = true
		},
    }
  }
</script>

<style lang="scss" scoped>
  .template-product{
	  height: 160vh;
  }
  .tatils{
	  color: #FFFFFF;
  }
  .tn-tabbar-height {
  	min-height: 120rpx;
  	height: calc(140rpx + env(safe-area-inset-bottom) / 2);
  }
  
  /* 用户头像 start */
  .logo-image {
    width: 110rpx;
    height: 110rpx;
    position: relative;
  }
  
  .logo-pic {
    background-size: cover;
    background-repeat: no-repeat;
    // background-attachment:fixed;
    background-position: top;
    box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
    border-radius: 10rpx;
    overflow: hidden;
    // background-color: #FFFFFF;
  }
  
  /* 胶囊*/
  .tn-custom-nav-bar__back {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    box-sizing: border-box;
    background-color: rgba(0, 0, 0, 0.15);
    border-radius: 1000rpx;
    border: 1rpx solid rgba(255, 255, 255, 0.5);
    color: #FFFFFF;
    font-size: 18px;
    
    .icon {
      display: block;
      flex: 1;
      margin: auto;
      text-align: center;
    }
    
    &:before {
      content: " ";
      width: 1rpx;
      height: 110%;
      position: absolute;
      top: 22.5%;
      left: 0;
      right: 0;
      margin: auto;
      transform: scale(0.5);
      transform-origin: 0 0;
      pointer-events: none;
      box-sizing: border-box;
      opacity: 0.7;
      background-color: #FFFFFF;
    }
  }
  
  /* 轮播视觉差 start */
  .card-swiper {
    height: 400rpx !important;
  }
    
  .card-swiper swiper-item {
    width: 750rpx !important;
    left: 0rpx;
    box-sizing: border-box;
    // padding: 0rpx 30rpx 90rpx 30rpx;
    overflow: initial;
  }
    
  .card-swiper swiper-item .swiper-item {
    width: 100%;
    display: block;
    height: 100%;
    transform: scale(1);
    transition: all 0.2s ease-in 0s;
    overflow: hidden;
  }
    
  .card-swiper swiper-item.cur .swiper-item {
    transform: none;
    transition: all 0.2s ease-in 0s;
  }
  
  .image-banner{
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .image-banner image{
    width: 100%;
    height: 100%;
	background-repeat: repeat-x;
  }
  
  /* 轮播指示点 start*/
  .indication{
    z-index: 9999;
    width: 100%;
    height: 36rpx;
    position: absolute;
    display:flex;
    flex-direction:row;
    align-items:center;
    justify-content:center;
  }
  
  .spot{
    background-color: #FFFFFF;
    opacity: 0.6;
    width: 10rpx;
    height: 10rpx;
    border-radius: 20rpx;
    top: -60rpx;
    margin: 0 8rpx !important;
    position: relative;
  }
  
  .spot.active{
    opacity: 1;
    width: 30rpx;
    background-color: #FFFFFF;
  }
  
  /* 间隔线 start*/
  .tn-strip-bottom-min {
    width: 100%;
    border-bottom: 1rpx solid #F8F9FB;
  }
  
  /* 间隔线 start*/
  .tn-strip-bottom {
   width: 100%;
   border-bottom: 20rpx solid rgba(241, 241, 241, 0.8);
  }
   /* 间隔线 end*/
  /* 标题 start */
  .nav_title {
    -webkit-background-clip: text;
    color: transparent;
    
    &--wrap {
      position: relative;
      display: flex;
      height: 120rpx;
      font-size: 46rpx;
      align-items: center;
      justify-content: center;
      font-weight: bold;
      background-image: url(https://resource.tuniaokj.com/images/title_bg/title44.png);
      background-size: cover;
    }
  }
  /* 标题 end */
  
  /* 底部tabbar start*/
  .footerfixed{
   position: fixed;
   width: 100%;
   bottom: 0;
   z-index: 999;
   background-color: #FFFFFF;
   box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);
  }
  
  /* 标签内容 start*/
  .tn-tag-content {
    &__item {
      display: inline-block;
      line-height: 45rpx;
      padding: 10rpx 30rpx;
      margin: 20rpx 20rpx 5rpx 0rpx;
      
      &--prefix {
        padding-right: 10rpx;
      }  
    }
  }
  /* 标签内容 end*/
  
  /* 内容图 start */
  .content-backgroup {
    z-index: -1;
  
    .backgroud-image {
      border-radius: 15rpx;
      width: 100%;
    }
  }
  /* 内容图 end */
  
  /* 商家商品 start*/
  .tn-blogger-content {
    &__wrap {
      box-shadow: 0rpx 0rpx 50rpx 0rpx rgba(0, 0, 0, 0.07);
      border-radius: 20rpx;
      margin: 15rpx;
    }
    
    &__info {
      &__btn {
        margin-right: -12rpx;
        opacity: 0.5;
      }
    }
    
    &__label {
      &__item {
        line-height: 45rpx;
        padding: 0 10rpx;
        margin: 5rpx 18rpx 0 0;
        
        &--prefix {
          color: #E83A30;
          padding-right: 10rpx;
        }
      }
      
      &__desc {
        line-height: 35rpx;
      }
    }
    
    &__main-image {
      border-radius: 16rpx 16rpx 0 0;
      
      &--1 {
        max-width: 690rpx;
        min-width: 690rpx;
        max-height: 400rpx;
        min-height: 400rpx;
      }
      
      &--2 {
        max-width: 260rpx;
        max-height: 260rpx;
      }
      
      &--3 {
        height: 212rpx;
        width: 100%;
      }
    }
    
    &__count-icon {
      font-size: 24rpx;
      padding-right: 5rpx;
    }
  }
  
  .image-book{
    padding: 150rpx 0rpx;
    font-size: 16rpx;
    font-weight: 300;
    position: relative;
  }
  .image-picbook{
    background-size: cover;
    background-repeat:no-repeat;
    // background-attachment:fixed;
    background-position:top;
    border-radius: 15rpx 15rpx 0 0;
  }
  
  /* 毛玻璃*/
  .dd-glass {
     width: 100%;
     backdrop-filter: blur(20rpx);
    -webkit-backdrop-filter: blur(20rpx);
  }
  .footer {
      position: fixed;
      left: 0;
      bottom: 0;
      width: 100%;
	  overflow: hidden;
    }
</style>
